import { http } from "@/utils/http";
import type { BlogVo, TagVo } from "@/type/post.ts";
import type { TagDetail } from "@/type";

interface getTagListReq {
  total: number;
  list: TagVo[];
}

interface TagReq {
  getTagList: () => Promise<getTagListReq>;
  getTagDetail: (id: number, params: any) => Promise<TagDetail>;
  getTagArticleList: (id: number) => Promise<BlogVo[]>;
}

export const tagApi: TagReq = {
  getTagList: () => {
    return http.get<getTagListReq>("/tag/list");
  },
  getTagDetail: (id: number, params: any) => {
    return http.get<TagDetail>(`/tag/${id}/detail`, { params });
  },
  getTagArticleList: (id: number) => {
    return http.get<BlogVo[]>(`/tag/getPostByTagId?id=${id}`, {
      headers: {
        RequestType: "front",
      },
    });
  },
};
